package com.skynet.supervision.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
public enum UserAccountStatus {
    NORMAL(1, "正常"),
    DISABLED(2, "已禁用"),
    UNKNOWN(-1, "未知");

    @Getter
    private final Integer status;
    @Getter
    private final String desc;

    public static UserAccountStatus of(Integer status) {
        if (status != null) {
            for (UserAccountStatus s : UserAccountStatus.values()) {
                if (s.getStatus().equals(status)) {
                    return s;
                }
            }
        }
        return UNKNOWN;
    }

    public static boolean isValid(Integer status) {
        return !of(status).equals(UNKNOWN);
    }
}
